package StudyCode.summary.mycollection;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class IteratorToSet {
	public static <T> Set<T> toSet(Iterator<? extends T> iteration) {
		Set<T> elements = new HashSet<T>(1);
		while (iteration.hasNext()) {
			elements.add(iteration.next());
		}
		return elements;
	}
}
